package com.itcast.donkey.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.itcast.donkey.R;
import com.itcast.donkey.adapters.SeachAbroadAdapter;
import com.itcast.donkey.adapters.SeachDomesticAdapter;

/**
 * Created by lanouhn on 16/8/26.
 */
public class DomesticFragment extends Fragment {
    private RecyclerView recyclerView;
    private SeachDomesticAdapter adapter;

    private String[] provinceName = {"台湾", "香港", "澳门", "上海", "云南", "四川", "北京", "浙江", "广东", "江苏", "福建", "陕西", "青海", "西藏", "甘肃", "广西",
            "重庆", "山东", "湖南", "内蒙古", "海南", "湖北", "辽宁", "新疆", "安徽", "黑龙江", "贵州", "河南", "山西", "天津", "河北", "吉林", "江西", "宁夏"};

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_domestic, null);
        return view;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        recyclerView = (RecyclerView) getView().findViewById(R.id.recyclerView_domestic);

        GridLayoutManager gm = new GridLayoutManager(getActivity(), 3);
        gm.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(gm);

        adapter = new SeachDomesticAdapter(getActivity(), provinceName);
        recyclerView.setAdapter(adapter);

//        // 初始化，只需要调用一次
//        AssetsDatabaseManager.initManager(getActivity().getApplication());
//        // 获取管理对象，因为数据库需要通过管理对象才能够获取
//        AssetsDatabaseManager mg = AssetsDatabaseManager.getManager();
//        // 通过管理对象获取数据库
//        SQLiteDatabase db1 = mg.getDatabase("db1.db");
//        // 对数据库进行操作
//        db1.execSQL("insert into tb([ID],[content]) values(null, 'db1');");
    }
}
